package cn.the.angry.model;

import java.awt.image.BufferedImage;

import org.jbox2d.collision.shapes.PolygonDef;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.World;

import cn.the.angry.physics.AngryRectangle;

public class RectBaseElement extends Actor {
	private AngryRectangle rect;

	public PolygonDef getRectDef() {
		return rect.getRectDef();
	}

	public RectBaseElement(final BufferedImage[] images) {
		super(images, true);
	}

	
	public void create(World _world, float _x, float _y, float _angle){
		rect = new AngryRectangle(_world, _x, _y, 0.2f, 0.8f, 0.2f, w, h, _angle, this);
		setBinding(true);
		setWorld(_world);
	}
	
	public void create(World _world, float _x, float _y){
		create(_world, _x, _y, 0);
	}
	
	@Override
	public void bind() {
//		getSprite().setAttributes(rect.getPosition().x-w/2, rect.getPosition().y-h/2
//				, rect.getBody().getAngle());
		getSprite().setCenterX(rect.getBody().getMemberPosition().x);
		getSprite().setCenterY(rect.getBody().getMemberPosition().y);
		getSprite().setAngle(rect.getBody().getAngle());
	}

	
	@Override
	public Body getBody() {
		return rect.getBody();
	}

	@Override
	public BodyDef getBodyDef() {
		return rect.getBodyDef();
	}
	
	@Override
	public void needChangedPic(int damagehp){
		
	}


}
